import pytest
from api_test.api.contact.dept_api import ContactApi


@pytest.fixture(name="contact", scope="session")
def init_calendar():
    print("setup_module")
    contact = ContactApi()
    yield contact
    # 后置清除数据，teardown_module
    print(f"\nteardown_module {contact.user_ids}")
    if contact.user_ids:
        for calendar_id in contact.user_ids:
            res = contact.delete(calendar_id)
            # print(res)
            if res.get('code') != 0:
                if res.get('code') != 191003:
                    print(f"\n{calendar_id} 删除失败 {res}")
                    return f"\n{calendar_id} 删除失败 {res}"
    print("\n数据后置OK! ")
